Skip to content

[Select] Fix flaky opening mouseup timing - #49024

Merged
michelengelen merged 1 commit into
mui:masterfrom
michelengelen:fix/select-opening-mouseup-flake
Sep 7, 2026
Merged

[Select] Fix flaky opening mouseup timing#49024
michelengelen merged 1 commit into
mui:masterfrom
michelengelen:fix/select-opening-mouseup-flake

Conversation

@michelengelen

Copy link
Copy Markdown
Member

Fixes a flaky WebKit failure in Select > pointer interactions > closes when the opening mouseup lands on the selected option after the selected-item delay.

The problem

SelectInput starts the selected-item timer inside the unselected timer's callback. The chain runs 200ms + 200ms. Each setTimeout adds its own jitter, so the real window drifts past 400ms on a loaded runner. The test slept 450ms, a 50ms margin. WebKit on CI misses that margin, the mouseup arrives while allowSelectedMouseUp is still false, and the menu never closes.

The fix

  • Start both timers from the mousedown. The unselected timer runs 200ms. The selected timer runs the full 400ms (SELECTED_MOUSE_UP_DELAY). The jitter no longer compounds, and the flat delay matches the existing code comments.
  • Widen the test sleeps: 450ms → 700ms for the selected-item window, 250ms → 400ms for the two drag-delay tests. The drag tests had the same 50ms margin.

Both timers were already cleared together in clearSelectionTimers, so no cleanup path depended on the nesting.

Test plan

  • pnpm test:browser Select -t "pointer interactions" passes in WebKit and Chromium (22 tests).
  • pnpm test:unit Select passes in jsdom (407 tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_013HgD6GEW3UxNRvC2abbTy9

The selected-item timer started inside the unselected timer's callback.
The chain compounds setTimeout jitter past the 400ms window. Slow CI
runners then miss the window and the WebKit test fails.

Start both timers from the mousedown instead. Widen the test sleeps to
give the timers real headroom.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HgD6GEW3UxNRvC2abbTy9
@code-infra-dashboard

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49024--material-ui.netlify.app/
QR code for https://deploy-preview-49024--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+2B(0.00%) ▼-2B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@zannager zannager added the scope: select Changes related to the select. label Aug 24, 2026
@zannager
zannager requested a review from silviuaavram August 24, 2026 14:30

@silviuaavram silviuaavram left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need both test change (timers increase) and a component change (starting the timers simultaneously)? Shouldn't only of them suffice?

@michelengelen

Copy link
Copy Markdown
Member Author

Why do we need both test change (timers increase) and a component change (starting the timers simultaneously)? Shouldn't only of them suffice?

Good question. Each of the changes targets a different problem.

Moving the second timer out of the first timer-callback makes sure time-jitter from the runner is minimized. So previously it was nominal timer 1 + jitter 1 + nominal timer 2 + jitter 2. This is now reduced to 2 separate nominal + jitter cases.

Now increasing the sleep times are meant to counter the uncontrollable jitter. The previous settings gave the tests not enough headroom for this. That's why I increased them. Its a safty measure that could have been enough on its own. The component change is just the extra cautious addition.

@michelengelen
michelengelen merged commit 937472f into mui:master Sep 7, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: select Changes related to the select.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants